package com.solocredit.finance.data.analyse.bean

import com.google.gson.Gson
import com.solocredit.finance.data.analyse.AnalyseBuilder
import com.solocredit.finance.data.analyse.AnalyseUtil

open class BaseBean(
    var token: String = "",
    var userId: String = "",
    var androidId: String = "",
    var advertId: String = "",
    var version: String = "",
    var product: String = "",
    var clientType: String = "",
    var aduid: String = "",
    var aduidPath: String = "",
    var isLimitAdTrackingEnabled: String = "",
    val apiVersion: String = "v3",
    var path: String = ""
) {
    init {
        this.token = AnalyseBuilder.token
        this.userId = AnalyseBuilder.userId
        this.version = AnalyseBuilder.libVersion
        this.product = AnalyseBuilder.product
        this.isLimitAdTrackingEnabled = AnalyseUtil.getAdEnabled().toString()
        this.androidId = AnalyseUtil.getAndroidId()
        this.advertId = AnalyseUtil.getAdId()
        this.aduid = AnalyseUtil.getAdId()
        this.aduidPath = AnalyseUtil.getAndroidId()
        this.clientType = "ANDROID"
    }

    /**
     * 根据path生成加密参数
     *
     * @param path 接口路径
     */
    open fun encrypt(path: String): String {
        this.path = path.replace("/", "")
        if (path.isBlank()) return ""

//        val content = Gson().toJson(this).trim()
//        return AesUtil.encryptDefault(content)
        return Gson().toJson(this).trim()
    }
}